package org.example.controller;

import org.example.Entity.Menu;
import org.example.Entity.Restaurant;
import org.example.Entity.UserEntity;
import org.example.Mapper.RestaurantMapper;
import org.example.utils.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/accountManage")
public class LoginController {
    @Autowired
    private RestaurantMapper restaurantMapper;
    @GetMapping("/login")
    public ResponseBody<Restaurant> login(){
        System.out.println("A request have been detected...");
        ResponseBody<Restaurant> rb = new ResponseBody<>();
        List<Restaurant> rList = restaurantMapper.getAllRestaurant();
        rb.setData(rList);
        return rb;
    }

    @GetMapping("/menu")
    public ResponseBody<Menu> getMenu(){
        System.out.println("A request have been detected...");
        Restaurant r = new Restaurant();
        r.setRestaurantID("0000000001");
        ResponseBody<Menu> rb = new ResponseBody<>();
        List<Menu> rList = restaurantMapper.getAllMenu(r);
        rb.setData(rList);
        return rb;
    }
}
